<%-- 
    Document   : sendEmail
    Created on : Nov 16, 2014, 11:17:15 AM
    Author     : user
--%>

<%@page import="newpackage.SendEmailKey"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="newpackage.ConnectionFactory"%>
<%@page import="java.sql.Connection"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body background="image.jpg">
    <center>
               <%!void sendMail(String fn, String un)throws Exception
                               {
             Connection con=ConnectionFactory.getConnection();
           Statement select=con.createStatement();
           String Query="SELECT file_details.secret_key,shared.user_name FROM file_details inner join shared on shared.id_fk=file_details.id where file_details.filename='"+fn+"' and user_name='"+un+"'";
           ResultSet rs=select.executeQuery(Query);
           String s1="";
           String s2="";
         while(rs.next())
                           {
         //     SendEmailKey.sendMail(rs.getString(2),rs.getString(1));
             s1=rs.getString(2);
             s2=rs.getString(1);
              
          }
           SendEmailKey.sendMail(s1,s2);
        }
        
%>

<%
sendMail(request.getParameter("file_name"),(String)session.getAttribute("user_name"));
RequestDispatcher rd=request.getRequestDispatcher("ViewFile.jsp");
rd.forward(request, response);

%>
</center>
    </body>
</html>
